﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Castle.MonoRail.Framework;
using Rodunu.Movies.Interfaces.Movie;
using Rodunu.Movies.Logic.Movie;

namespace Rodunu.Movies.Web.ViewComponents
{
    public class MovieLinksComponent : ViewComponent
    {
        private readonly IUserMovies _userMoviesLogic;

        public MovieLinksComponent()
        {
            _userMoviesLogic = new UserMoviesLogic();
        }

        public override void Render()
        {
            //if (ComponentParams["CurrentMovieId"] != null && ComponentParams["UserId"] != null)
            //{
            long movieId = Convert.ToInt64(Context.ComponentParameters["CurrentMovieId"]);
            long userId = Convert.ToInt64(Context.ComponentParameters["UserId"]);
            PropertyBag["movieid"] = movieId;
            PropertyBag["userid"] = userId;
            PropertyBag["UserMovieLinks"] = _userMoviesLogic.GetLinkMovies(movieId, userId);
            PropertyBag["UserMovieFriendLinks"] = _userMoviesLogic.GetFriendsUserMoviesForMovies(movieId, userId);
            //}
            
            base.Render();
        }
    }
}
